package com.chilly.io;

import org.junit.jupiter.api.Test;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

/**
 * Created by Chilly Cui on 2020/9/24.
 */
public class ByteArrayDemo {

    @Test
    void test1() {
        ByteArrayInputStream bis = new ByteArrayInputStream("data".getBytes());
        ByteArrayOutputStream bos = new ByteArrayOutputStream();

        int len = 0;
        while ((len = bis.read()) != -1) {
            bos.write(len);
        }
//        输出data
        System.out.println(new String(bos.toByteArray()));

    }
}
